﻿using System;
using System.Web.Mvc;
using OperationPlugins.Validators.DataAnnotations;

namespace OperationPlugins.Mvc.Filters
{
    /// <summary>
    /// Used to tell that the current action method should ignore all <see cref="UsePluginValidatorsAttribute"/> attributes.
    /// 
    /// To use this, apply this attribute to an action method or to a controller class.
    /// </summary>
    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
    public class DisablePluginsValidationAttribute : FilterAttribute, IAuthorizationFilter
    {
        void IAuthorizationFilter.OnAuthorization(AuthorizationContext filterContext)
        {
            OperationPluginsContext.Current.DisablePluginsValidation = true;
        }
       
    }
}
